//
//  RingSubscribeSectionHeader.m
//  BaseProject
//
//  Created by 王洋 on 2021/3/18.
//  Copyright © 2021 王洋. All rights reserved.
//

#import "RingSubscribeSectionHeader.h"

@interface RingSubscribeSectionHeader ()

@property (weak, nonatomic) IBOutlet UIView *bgView;

@property (weak, nonatomic) IBOutlet UIImageView *storeIcon;

@property (weak, nonatomic) IBOutlet UILabel *storeName;

@property (weak, nonatomic) IBOutlet UILabel *statusLab;

@end

@implementation RingSubscribeSectionHeader

- (void)awakeFromNib {
    [super awakeFromNib];
    
}

- (void)fillWithModel:(CommonSubscribeRingModel *)model {
    
    
    NSString *logo = [TT_OSSManager reSourceUrl:model.logoUrl type:BA_resizeType_plus];
    [self.storeIcon sd_setImageWithURL:[NSURL URLWithString:logo] placeholderImage:[UIImage imageNamed:@"placeholder"]];
    self.storeName.text = model.sellerName;
    
    ////领取状态1待领取2已领取3已取消
    switch (model.type) {
        case 1:{
            self.statusLab.text = @"待领取";
        } break;
        case 2:{
            self.statusLab.text = @"已领取";
        } break;
        case 3:{
            self.statusLab.text = @"已取消";
        } break;
        default:{
            self.statusLab.text = @"未知状态";
        } break;
    }
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [self.bgView pp_clipCorners:UIRectCornerTopLeft|UIRectCornerTopRight radius:6];
        
        [self.storeIcon pp_clipCorners:UIRectCornerAllCorners radius:self.storeIcon.frame.size.height/2];
    });
}



@end
